/*
 +-----------------------------------------------------------------------------------------------+
 | Project : UKAPI
 +-----------------------------------------------------------------------------------------------+
 | Project Description : Universal & Kernel API
 +-----------------------------------------------------------------------------------------------+
 | File Description :
 |   Com
 |                                                 
 +-----------------------------------------------------------------------------------------------+
 | Licence : MIT Licence
 +-----------------------------------------------------------------------------------------------+
 | Copyright (c) 2006 Olivier Vanhoucke
 | 
 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
 | and associated documentation files (the "Software"), to deal in the Software without 
 | restriction, including without limitation the rights to use, copy, modify, merge, publish, 
 | distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 
 | Software is furnished to do so, subject to the following conditions:
 | 
 | The above copyright notice and this permission notice shall be included in all copies or 
 | substantial portions of the Software.
 | 
 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
 | BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 +-----------------------------------------------------------------------------------------------+
*/


/**
 * Inclusions standards
 */
#include <ukapi.h>

/**
 * Inclusions locales
 */

typedef struct
{
	pstream_driver_t		pdriver;
} com_t, * pcom_t;

_public result_t com_open( pcom_t pcom, string_t drv, string_t address, ushort_t port )
{
	pcom->pdriver = device_open( drv );

	if ( pcom->pdriver == null )
	{

	}

	//device_iocontrol( pcom->pdriver ); //connect
	
}

_public result_t com_close( pcom_t pcom )
{
	device_close( pcom->pdriver );
}

_public result_t com_read( pcom_t pcom )
{
	device_read( pcom->pdriver );
}

_public result_t com_write( pcom_t pcom )
{
	device_write( pcom->pdriver );
}

_public result_t com_getlasterror( pcom_t pcom ) //?????????????????????????
{
	//device_iocontrol( pcom->pdriver );
}

_public result_t com_status( pcom_t pcom )
{
	//device_iocontrol( pcom->pdriver );
}

_public result_t com_waitconnect( pcom_t pcom, pcom_t pcom_client )
{
	pcom_client->pdriver = memory_allocate( sizeof( stream_driver_t ) );

	if ( pcom_client->pdriver == null )
	{

	}

	// duplicate instance
	memory_copy( pcom_client->pdriver, sizeof( stream_driver_t ), pcom->pdriver, sizeof( stream_driver_t ) );

	// but change contexte
	pcom_client->pdriver->instance_context = 

	//device_iocontrol( pcom->pdriver );
}

_public result_t com_configure( pcom_t pcom )
{
	//device_iocontrol( pcom->pdriver );
}

_public result_t com_connect( pcom_t pcom )
{
	//device_iocontrol( pcom->pdriver );
}
